﻿<!-- #include file="../Include/Admin_Onlogin.asp" -->
<%
Dim sqlAuth, rsAuth, PurviewID
Dim TopDir,FsoFile,AllFileSize,MobanDir
Dim FileType,ThisDir,DirFiles,DirFolder
Set Fso=Server.CreateObject(Fso_Sys)
ThisDir=Trim(Request("ThisDir"))
FileType=Trim(Request("FileType"))
Data_Name = "{prefix}Moban"
strFileName = "Admin_Moban.asp"
If FileType="css" Then
	sqlAuth = "Select AuthID From Admin_Auth Where href='Moban/" & strFileName & "?FileType=css' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		PurviewID = 0
	Else
		PurviewID = rsAuth(0)
		CheckPurview PurviewID,0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
	MobanDir=SkinDir
Else
	sqlAuth = "Select AuthID From Admin_Auth Where href='Moban/" & strFileName & "' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		PurviewID = 0
	Else
		PurviewID = rsAuth(0)
		CheckPurview PurviewID,0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
	FileType="html"
	MobanDir=TemplateDir
End If
TopDir=Replace(InstallDir&MobanDir,"//","/")
If ThisDir<>"" Then
	ThisDir=Replace(ThisDir & "/","//","/")
End If
Select Case Action
Case "Add"
	If FileType="css" Then
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Skin/Add' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,0
		Else
			CheckPurview rsAuth(0),0
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	Else
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Moban/Add' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,0
		Else
			CheckPurview rsAuth(0),0
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	End If
    Call Add()
Case "SaveAdd"
	If FileType="css" Then
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Skin/Insert' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,1
		Else
			CheckPurview rsAuth(0),1
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	Else
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Moban/Insert' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,1
		Else
			CheckPurview rsAuth(0),1
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	End If
    Call SaveAdd()
Case "Modify"
	If FileType="css" Then
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Skin/Edit' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,0
		Else
			CheckPurview rsAuth(0),0
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	Else
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Moban/Edit' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,0
		Else
			CheckPurview rsAuth(0),0
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	End If
    Call Modify()
Case "SaveModify"
	If FileType="css" Then
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Skin/Update' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,1
		Else
			CheckPurview rsAuth(0),1
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	Else
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Moban/Update' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,1
		Else
			CheckPurview rsAuth(0),1
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	End If
    Call SaveModify()
Case "Update"
	If FileType="css" Then
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Skin/Update' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,1
		Else
			CheckPurview rsAuth(0),1
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	Else
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Moban/Update' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,1
		Else
			CheckPurview rsAuth(0),1
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	End If
    Call Update()
Case "MobanPreview"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Moban/View' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,0
	Else
		CheckPurview rsAuth(0),0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call MobanPreview()
Case "ModifyContent"
    Call ModifyContent()
Case "Del"
	If FileType="css" Then
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Skin/Del' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,1
		Else
			CheckPurview rsAuth(0),1
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	Else
		sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Moban/Del' Order By sort Asc,AuthID Asc"
		Call Exec(rsAuth,sqlAuth,2)
		If rsAuth.BOF And rsAuth.EOF Then
			CheckPurview 0,1
		Else
			CheckPurview rsAuth(0),1
		End If
		rsAuth.Close
		Set rsAuth = Nothing
	End If
    Call DelAll()
Case Else
    Call Main()
End Select
If FoundErr = True Then
	Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Call CloseConn()

Sub Main()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		On Error Resume Next
		FileType = Trim(Code_Form("FileType"))
		ThisDir = Trim(Code_Form("ThisDir"))
		If FileType="css" Then
			MobanDir=SkinDir
		Else
			FileType="html"
			MobanDir=TemplateDir
		End If
		TopDir=Replace(InstallDir&MobanDir,"//","/")
		If ThisDir<>"" Then
			ThisDir=Replace(ThisDir & "/","//","/")
		End If
		Set FsoFile = Fso.GetFolder(Server.MapPath(TopDir & ThisDir))
		If Err or TopDir="/" Then
			Set FsoFile = nothing
			Response.Write "{""code"":201,""msg"":""\u627e\u4e0d\u5230\u76ee\u5f55\uff0c\u53ef\u80fd\u53c2\u6570\u914d\u7f6e\u9519\u8bef\uff01""}" & vbCrLf
			Response.End()
		End If
		AllFileSize = FsoFile.size
		Dim FolderNuns,FileNums,i,totalPut,data
		FolderNuns = FsoFile.SubFolders.count
		FileNums = FsoFile.Files.count
		totalPut = FolderNuns+FileNums
		If ThisDir<>"" Then
			'data = data & "{""name"":"".."",""getname"":"""",""gettype"":"""",""ico"":""../Plugins/assets/images/ext/folder.png"",""size"":"""",""time"":"""",""folder"":1}"
		End If
		For Each DirFolder in FsoFile.SubFolders
			If FileType="html" Then
				If data="" Then
					data = data & "{""name"":"""&ToUnicode(DirFolder.name)&""",""getname"":"""&ToUnicode(GetMobanName(DirFolder.name))&""",""gettype"":"""&ToUnicode(GetMobanTypeName(DirFolder.name))&""",""ico"":""../Plugins/assets/images/ext/folder.png"",""size"":"""&GetSize(DirFolder.size,"b")&""",""time"":"""&Time_Type(DirFolder.DateLastModified,1)&""",""folder"":1}"
				Else
					data = data & ",{""name"":"""&ToUnicode(DirFolder.name)&""",""getname"":"""&ToUnicode(GetMobanName(DirFolder.name))&""",""gettype"":"""&ToUnicode(GetMobanTypeName(DirFolder.name))&""",""ico"":""../Plugins/assets/images/ext/folder.png"",""size"":"""&GetSize(DirFolder.size,"b")&""",""time"":"""&Time_Type(DirFolder.DateLastModified,1)&""",""folder"":1}"
				End If
			End If
		Next
		For Each DirFiles in FsoFile.Files
			strFileType=lcase(mid(DirFiles.Name,instrrev(DirFiles.Name,".")+1))
			If strFileType=FileType Then
				If data="" Then
					data = data & "{""name"":"""&ToUnicode(DirFiles.name)&""",""getname"":"""&ToUnicode(GetMobanName(ThisDir&DirFiles.name))&""",""gettype"":"""&ToUnicode(GetMobanTypeName(ThisDir&DirFiles.name))&""",""ico"":""../Plugins/assets/images/ext/"&FileType&".png"",""size"":"""&GetSize(DirFiles.size,"b")&""",""time"":"""&Time_Type(DirFiles.DateLastModified,1)&""",""folder"":0}"
				Else
					data = data & ",{""name"":"""&ToUnicode(DirFiles.name)&""",""getname"":"""&ToUnicode(GetMobanName(ThisDir&DirFiles.name))&""",""gettype"":"""&ToUnicode(GetMobanTypeName(ThisDir&DirFiles.name))&""",""ico"":""../Plugins/assets/images/ext/"&FileType&".png"",""size"":"""&GetSize(DirFiles.size,"b")&""",""time"":"""&Time_Type(DirFiles.DateLastModified,1)&""",""folder"":0}"
				End If
			End If
		Next
		Set FsoFile = nothing
		If totalPut = 0 Then
			Response.Write "{""code"":201,""msg"":""\u65e0\u6570\u636e""}" & vbCrLf
		Else
			Response.Write "{""code"":0,""msg"":""\u83b7\u53d6\u6210\u529f!"",""count"":"&totalPut&",""data"":["&data&"],""rel"":1}" & vbCrLf
		End If
		Response.End()
	Else
		Response.Write "<!DOCTYPE html>" & vbCrLf
		Response.Write "<head>" & vbCrLf
		Response.Write "<title>模板管理</title>" & vbCrlf
		Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
		Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
		Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
		Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
		Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
		Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
		Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
		Response.Write "<link rel=""stylesheet"" href=""../Style/global.css"" media=""all"">" & vbCrLf
		Response.Write "<link rel=""stylesheet"" href=""../Style/font.css"" media=""all"">" & vbCrLf
		Response.Write "<script type='text/javascript'>" & vbCrLf
		Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
		Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
		Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
		Response.Write "</head>" & vbCrlf
		Response.Write "<body>" & vbCrlf
		Response.Write "<div class=""admin-main layui-anim layui-anim-upbit"">" & vbCrLf
		Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrLf
		Response.Write "        <legend>模板管理</legend>" & vbCrLf
		Response.Write "    </fieldset>" & vbCrLf
		Response.Write "    <blockquote class=""layui-elem-quote"">" & vbCrLf
		If FileType="html" Then 
			Response.Write "        <a href=""?Action=Main&FileType=" & FileType & """ class=""layui-btn layui-btn-sm layui-btn-normal"">" & vbCrlf
			Response.Write "            <i class=""fa fa-home""></i> 返回主目录" & vbCrlf
			Response.Write "        </a>" & vbCrLf
		End If
		Response.Write "        <a href=""?Action=Add&FileType=" & FileType & "&ThisDir=" & ThisDir & """ class=""layui-btn layui-btn-sm"">" & vbCrlf
		Response.Write "            <i class=""fa fa-plus""></i> 添加模板" & vbCrlf
		Response.Write "        </a>" & vbCrLf
		Response.Write "        <a href=""?Action=Main"" class=""layui-btn layui-btn-sm"
		If FileType="html" Then Response.Write " layui-btn-danger"
		Response.Write """>" & vbCrlf
		Response.Write "            <i class=""fa fa-file-code-o""></i> HTML" & vbCrlf
		Response.Write "        </a>" & vbCrlf
		Response.Write "        <a href=""?FileType=css"" class=""layui-btn layui-btn-sm"
		If FileType="css" Then Response.Write " layui-btn-danger"
		Response.Write """>" & vbCrlf
		Response.Write "            <i class=""fa fa-css3""></i> CSS" & vbCrlf
		Response.Write "        </a>" & vbCrlf
		If ThisDir<>"" Then
			Response.Write "        <a href=""?Action=Main&FileType=" & FileType & """ style=""float: right;"" class=""layui-btn layui-btn-sm layui-btn-normal"">" & vbCrlf
			Response.Write "            <i class=""fa fa-arrow-up""></i> 上一目录" & vbCrlf
			Response.Write "        </a>" & vbCrlf
		End If
		Response.Write "    </blockquote>" & vbCrLf
		Response.Write "    <table class=""layui-table"" id=""list"" lay-filter=""list""></table>" & vbCrLf
		Response.Write "</div>" & vbCrLf
		Response.Write "<script type=""text/html"" id=""name"">" & vbCrLf
		'Response.Write "    {{# if(d.folder==1){ }}" & vbCrLf
		'Response.Write "    {{# if(d.name=='..'){ }}" & vbCrLf
		'Response.Write "    <a href=""?Action=Main&FileType=" & FileType & """><img src=""{{d.ico}}"" style=""width:30px;margin-right:10px"">{{d.name}}</a>" & vbCrlf
		'Response.Write "    {{# }else{  }}" & vbCrLf
		'Response.Write "    <a href=""?Action=Main&FileType=" & FileType & "&ThisDir=" & ThisDir & "{{d.name}}""><img src=""{{d.ico}}"" style=""width:30px;margin-right:10px"">{{d.name}}</a>" & vbCrlf
		'Response.Write "    {{# } }}" & vbCrLf
		'Response.Write "    {{# }else{  }}" & vbCrLf
		'Response.Write "    <a href=""?Action=Modify&MobanName={{d.name}}&FileType=" & FileType & "&ThisDir=" & ThisDir & """><img src=""{{d.ico}}"" style=""width:30px;margin-right:10px"">{{d.name}}</a>" & vbCrlf
		'Response.Write "    {{# } }}" & vbCrLf
		Response.Write "    <img src=""{{d.ico}}"" style=""width:30px;margin-right:10px"">{{d.name}}" & vbCrlf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type=""text/html"" id=""getname"">" & vbCrLf
		Response.Write "    <span onmouseover=""layer.tips('单击重命名',this,{tips: [1, '#000']});"" onmouseout=""layer.closeAll();"">{{d.getname}}</span>" & vbCrlf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type=""text/html"" id=""action"">" & vbCrLf
		Response.Write "    {{# if(d.folder==1){ }}" & vbCrLf
		Response.Write "    {{# if(d.name=='..'){ }}" & vbCrLf
		Response.Write "    <a href=""?Action=Main&FileType=" & FileType & """ class=""layui-btn layui-btn-xs layui-btn-normal""><i class=""fa fa-folder-open-o""></i> 上一目录</a>" & vbCrlf
		Response.Write "    {{# }else{  }}" & vbCrLf
		Response.Write "    <a href=""?Action=Main&FileType=" & FileType & "&ThisDir=" & ThisDir & "{{d.name}}"" class=""layui-btn layui-btn-xs layui-btn-normal""><i class=""fa fa-folder-open-o""></i> 打开</a>" & vbCrlf
		Response.Write "    {{# } }}" & vbCrLf
		Response.Write "    {{# }else{  }}" & vbCrLf
		Response.Write "    <a href=""?Action=Modify&MobanName={{d.name}}&FileType=" & FileType & "&ThisDir=" & ThisDir & """ class=""layui-btn layui-btn-xs""><i class=""fa fa-edit""></i> 编辑</a>" & vbCrlf
		Response.Write "    <a onClick=""ItemDialog('MobanView','浏览文件！','" & TopDir & ThisDir & "{{d.name}}',800,500);"" class=""layui-btn layui-btn-xs layui-btn-normal""><i class=""fa fa-chrome""></i> 浏览</a>" & vbCrlf
		Response.Write "    <a class=""layui-btn layui-btn-xs layui-btn-danger"" lay-event=""del""><i class=""fa fa-trash-o""></i> 删除</a>" & vbCrLf
		If FileType="html" Then Response.Write "        <a href=""?Action=MobanPreview&MobanName={{d.name}}&FileType=" & FileType & "&ThisDir=" & ThisDir & """ target=""_blank"" class=""layui-btn layui-btn-xs layui-btn-normal""><i class=""fa fa-eye""></i> 预览</a>" & vbCrLf
		Response.Write "    {{# } }}" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script>" & vbCrLf
		Response.Write "    layui.use('table', function() {" & vbCrLf
		Response.Write "        var table = layui.table, $ = layui.jquery;" & vbCrLf
		Response.Write "        var tableIn=table.render({" & vbCrLf
		Response.Write "            elem: '#list'," & vbCrLf
		Response.Write "            url: '?Action=Main'," & vbCrLf
		Response.Write "            method: 'post'," & vbCrLf
		Response.Write "            where: { //设定异步数据接口的参数" & vbCrLf
		Response.Write "                FileType: '"&FileType&"',ThisDir: '"&ThisDir&"'" & vbCrLf
		Response.Write "            }," & vbCrLf
		Response.Write "            cellMinWidth: 80," & vbCrLf
		Response.Write "            cols: [[" & vbCrLf
		Response.Write "                {field: 'name', title: '文件名称', width: 200, templet: '#name', fixed: true}," & vbCrLf
		Response.Write "                {field: 'getname', title: '文件别名', width: 200, templet: '#getname', edit: 'text'}," & vbCrLf
		Response.Write "                {field: 'gettype', title: '模板类型', width: 100}," & vbCrLf
		Response.Write "                {field: 'size', title: '文件大小', width: 200}," & vbCrLf
		Response.Write "                {field: 'time', title: '修改时间', width: 160}," & vbCrLf
		Response.Write "                {title: '操作', width: 300, align: 'center', toolbar: '#action'}" & vbCrLf
		Response.Write "            ]]" & vbCrLf
		Response.Write "        });" & vbCrLf
		Response.Write "        //监听单元格编辑" & vbCrlf
		Response.Write "        table.on('edit(list)',function(obj) {" & vbCrlf
		Response.Write "            var value = obj.value, data = obj.data, field = obj.field;" & vbCrlf
		Response.Write "            $.ajax({" & vbCrLf
		Response.Write "                type: 'post'," & vbCrLf
		Response.Write "                url: '?Action=Update'," & vbCrLf
		Response.Write "                data: {MobanName:data.name,MobanGetName:value,FileType:'"&FileType&"',ThisDir:'"&ThisDir&"'}," & vbCrLf
		Response.Write "                dataType: 'json'," & vbCrLf
		Response.Write "                success: function(res) {" & vbCrLf
		Response.Write "                    if (res.code == 1) {" & vbCrlf
		Response.Write "                        layer.msg(res.msg, {time: 1000, icon: 1}, function () {" & vbCrlf
		Response.Write "                            tableIn.reload({ where: {FileType: '"&FileType&"', ThisDir: '"&ThisDir&"'} });" & vbCrlf
		Response.Write "                        });" & vbCrlf
		Response.Write "                    }else{" & vbCrlf
		Response.Write "                        layer.msg(res.msg,{time:1000,icon:2});" & vbCrLf
		Response.Write "                    }" & vbCrlf
		Response.Write "                }" & vbCrLf
		Response.Write "            });" & vbCrLf
		Response.Write "        });" & vbCrlf
		Response.Write "        table.on('tool(list)', function(obj) {" & vbCrLf
		Response.Write "            var data = obj.data;" & vbCrLf
		Response.Write "            if(obj.event === 'del'){" & vbCrLf
		Response.Write "                layer.confirm('你确定要删除吗？', function(index){" & vbCrLf
		Response.Write "                    $.ajax({" & vbCrLf
		Response.Write "                        type: 'post'," & vbCrLf
		Response.Write "                        url: '?Action=Del'," & vbCrLf
		Response.Write "                        data: {FileType: '"&FileType&"', ThisDir: '"&ThisDir&"', FileId:data.name}," & vbCrLf
		Response.Write "                        dataType: 'json'," & vbCrLf
		Response.Write "                        success: function(res) {" & vbCrLf
		Response.Write "                            if (res.code == 1) {" & vbCrLf
		Response.Write "                                layer.msg(res.msg,{time:1000,icon:1});" & vbCrLf
		Response.Write "                                obj.del();" & vbCrLf
		Response.Write "                            }else{" & vbCrLf
		Response.Write "                                layer.msg(res.msg,{time:1000,icon:2});" & vbCrLf
		Response.Write "                            }" & vbCrLf
		Response.Write "                        }" & vbCrLf
		Response.Write "                    });" & vbCrLf
		Response.Write "                    layer.close(index);" & vbCrLf
		Response.Write "                });" & vbCrLf
		Response.Write "            }" & vbCrLf
		Response.Write "        });" & vbCrLf
		Response.Write "    });" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "</body>" & vbCrLf & "</html>"
	End If
End Sub

Sub Add()
	Response.Write "<!DOCTYPE html>" & vbCrLf
	Response.Write "<head>" & vbCrLf
	Response.Write "<title>模板管理</title>" & vbCrlf
	Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
	Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
	Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
	Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
	Response.Write "<link rel='stylesheet' type='text/css' href='../Js/Codemirror/Codemirror.css'/>" & vbCrLf
	Response.Write "<link rel='stylesheet' type='text/css' href='../Plugins/editor/css/editormd.min.css'/>" & vbCrLf
	Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/global.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/font.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
	Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/Codemirror.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/xml.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/css.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/javascript.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/htmlmixed.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/mirrorframe.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/clipboard/clipboard.min.js""></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/editor/editormd.min.js""></script>" & vbCrLf
	Response.Write "</head>" & vbCrlf
	Response.Write "<body>" & vbCrlf
	Response.Write "<script language=""JavaScript"">" & vbCrlf
	Response.Write "function CssInsertCode(Val,Content) {" & vbCrlf
	Response.Write "if(Val != """" && Val != null){" & vbCrlf
	Response.Write "Val = Val.replace(""{$quot}"",""\"""");" & vbCrlf
	Response.Write "Val = Val.replace(""{$quot}"",""\"""");" & vbCrlf
	Response.Write "MobanContent.replaceSelection(Val,MobanContent.getCursor());" & vbCrlf
	Response.Write "MobanContent.focus()" & vbCrlf
	Response.Write "}" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "$(function(){" & vbCrLf
	Response.Write "$(""#MobanSetting img"").mousemove(function(){" & vbCrLf
	Response.Write "layer.tips($(this).attr(""dname""),this,{tips: [1, '#000']});" & vbCrLf
	Response.Write "});" & vbCrLf
	Response.Write "$(""#MobanSetting img"").mouseout(function(){" & vbCrLf
	Response.Write "layer.closeAll();" & vbCrLf
	Response.Write "});" & vbCrLf
	Response.Write "})" & vbCrLf
	Response.Write "</script>" & vbCrlf
	Response.Write "<form class='layui-form layui-form-pane' action=""" & strFileName & """ method=""post"" name=""myform"">" & vbCrlf
	Response.Write "<div class=""admin-main fadeInUp animated"">" & vbCrlf
	Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrlf
	Response.Write "        <legend>添加模板</legend>" & vbCrlf
	Response.Write "    </fieldset>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">文件名称：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""MobanName"" type=""text"" id=""MobanName"" size=""50"" value="""" placeholder=""请输入文件名称"" lay-verify=""MobanName"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">文件别名：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""MobanGetName"" type=""text"" id=""MobanGetName"" size=""50"" value="""" placeholder=""请输入文件别名"" lay-verify=""MobanGetName"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">文件类型：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-back"">" & vbCrlf
	Response.Write "            <input type=""radio"" name=""FileType"" lay-filter=""FileType"" value=""html"" title=""模版文件"" onClick=""MobanSetting.style.display='';MobanTypehtml.style.display='';MobanTypecss.style.display='none';"""
	If FileType="html" Then Response.Write " checked"
	Response.Write ">" & vbCrlf
	Response.Write "            <input type=""radio"" name=""FileType"" lay-filter=""FileType"" value=""css"" title=""CSS文件"" onClick=""MobanSetting.style.display='none';MobanTypehtml.style.display='none';MobanTypecss.style.display='';"""
	If FileType="css" Then Response.Write " checked"
	Response.Write ">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">模板类型：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-back"">" & vbCrlf
	Response.Write "            <span id=""MobanTypehtml"">" & vbCrlf
	Response.Write "                <input type=""radio"" name=""MobanType"" value=""0"" title=""导页模版"" lay-verify=""MobanType"">" & vbCrlf
	Response.Write "                <input type=""radio"" name=""MobanType"" value=""1"" title=""首页模版"" lay-verify=""MobanType"" checked>" & vbCrlf
	Response.Write "                <input type=""radio"" name=""MobanType"" value=""2"" title=""列表页模版"" lay-verify=""MobanType"">" & vbCrlf
	Response.Write "                <input type=""radio"" name=""MobanType"" value=""3"" title=""详情页模版"" lay-verify=""MobanType"">" & vbCrlf
	Response.Write "                <input type=""radio"" name=""MobanType"" value=""4"" title=""搜索页模版"" lay-verify=""MobanType"">" & vbCrlf
	Response.Write "                <input type=""radio"" name=""MobanType"" value=""5"" title=""公共模板"" lay-verify=""MobanType"">" & vbCrlf
	Response.Write "            </span>" & vbCrlf
	Response.Write "            <span id=""MobanTypecss"" style=""display:none;"">" & vbCrlf
	Response.Write "                <input type=""radio"" name=""MobanType"" value=""6"" title=""CSS样式"" lay-verify=""MobanType"">" & vbCrlf
	Response.Write "            </span>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item layui-form-text"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">内容：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-block"" style=""border:1px solid #e6e6e6;"">" & vbCrlf
	Response.Write "            <div id=""MobanSetting"""
	If FileType="css" Then Response.Write " style=""display:none;"""
	Response.Write ">" & CssSelect("MobanContent","mycss",Web_IndexShowSkinID) & "&nbsp;<b>使用标签：</b>[<a href='javascript:void(0);' onClick=""ItemDialogLabel('Test','常用标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/TemplateConfig.gif"" dname=""常用标签""/></a>&nbsp;&nbsp;<a href='javascript:void(0);' onClick=""ItemDialogLabel('Test','文字列表标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?Action=List&ChannelID=1&type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/articleList.gif"" dname=""文字列表标签"" /></a>&nbsp;&nbsp;<a href='javascript:void(0);' onclick=""ItemDialogLabel('Test','图片标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?Action=Image&ChannelID=1&type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/image.gif"" dname=""图片标签"" /></a>&nbsp;&nbsp;<a href='javascript:void(0);' onclick=""ItemDialogLabel('Test','Flash标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?Action=Flash&ChannelID=1&type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/videoList.gif"" dname=""Flash标签"" /></a>&nbsp;&nbsp;<a href='javascript:void(0);' onclick=""ItemDialogLabel('Test','Flash标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?Action=Flashqq&ChannelID=1&type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/imagePlayer.gif"" dname=""Flash标签"" /></a>&nbsp;&nbsp;<a href='javascript:void(0);' onclick=""ItemDialogLabel('Test','栏目标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?Action=Class&ChannelID=1&type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/ZList.gif"" dname=""栏目标签"" /></a>]</div>"
	Response.Write "<div id=""editormd""></div>" & vbCrlf
	Response.Write "<textarea name=""MobanContent"" id=""MobanContent"" style=""display:none;"" lay-verify=""MobanContent""></textarea>" & vbCrlf
	Response.Write "        <a href=""javascript:void(0);"" id=""copyCss"" class=""layui-btn layui-btn-normal""><i class=""layui-icon layui-icon-fonts-code""></i>复制</a>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "</div>" & vbCrlf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "MobanContent = editormd(""editormd"", {" & vbCrLf
	Response.Write "	width : ""100%""," & vbCrLf
	Response.Write "	height : ""300px""," & vbCrLf
	Response.Write "	watch : false," & vbCrLf
	Response.Write "	toolbar : false," & vbCrLf
	Response.Write "	codeFold : true," & vbCrLf
	Response.Write "	searchReplace : true," & vbCrLf
	Response.Write "	placeholder : ""请输入"&FileType&"代码""," & vbCrLf
	Response.Write "	value : document.getElementById(""MobanContent"").value," & vbCrLf
	Response.Write "	theme : ""default""," & vbCrLf
	Response.Write "	mode : ""text/"&FileType&"""," & vbCrLf
	Response.Write "	path : '../Plugins/editor/lib/'" & vbCrLf
	Response.Write "});" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<input name=""ThisDir"" type=""hidden"" id=""ThisDir"" value=""" & ThisDir & """><input type=""hidden"" name=""Action"" value=""SaveAdd"">" & Submit_Layui("提交添加","重新填写","确认要清空对话框内容？","javascript:history.back();","返回上一页","") & vbCrlf
	Response.Write "</form>" & vbCrlf
	Response.Write "<div id=""copyCssWrap"" class=""copyCssWrap layui-layer-wrap"">" & vbCrLf
	Response.Write "    <textarea id=""cssTextarea"" readonly=""readonly""></textarea>" & vbCrLf
	Response.Write "    <a href=""javascript:layer.closeAll('page');"" id=""copyCssBtn"" class=""layui-btn layui-btn-normal"" data-clipboard-target=""#cssTextarea"">一键复制</a>" & vbCrLf
	Response.Write "</div>" & vbCrLf
	Response.Write "<script>" & vbCrlf
	Response.Write "layui.use(['form'], function () {" & vbCrlf
	Response.Write "    var form = layui.form;" & vbCrlf
	Response.Write "    //监听复制事件" & vbCrlf
	Response.Write "    $(""#copyCss"").click(function () {" & vbCrLf
	Response.Write "        var currentCss = MobanContent.getValue();" & vbCrLf
	Response.Write "        if (currentCss !== ''){" & vbCrLf
	Response.Write "            $('#copyCssWrap textarea').val(currentCss);" & vbCrLf
	Response.Write "            layer.open({" & vbCrLf
	Response.Write "                type: 1" & vbCrLf
	Response.Write "                ,title: '<i class=""layui-icon layui-icon-fonts-code""></i> 复制'" & vbCrLf
	Response.Write "                ,id: 'Copy_Css'" & vbCrLf
	Response.Write "                ,content: $('#copyCssWrap')" & vbCrLf
	Response.Write "                ,maxWidth: '100%'" & vbCrLf
	Response.Write "            });" & vbCrLf
	Response.Write "        }" & vbCrLf
	Response.Write "    });" & vbCrLf
	Response.Write "    var clipboard = new ClipboardJS('#copyCssBtn');" & vbCrlf
	Response.Write "    clipboard.on('success', function(e) {" & vbCrlf
	Response.Write "        layer.msg('已复制');" & vbCrlf
	Response.Write "        e.clearSelection();" & vbCrlf
	Response.Write "    });" & vbCrlf
	Response.Write "    //自定义表单验证" & vbCrlf
	Response.Write "    form.verify({" & vbCrlf
	Response.Write "        MobanName: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""文件名称不能为空！请填写！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        MobanGetName: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""文件别名不能为空！请填写！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        MobanType: function (value, item) {" & vbCrlf
	Response.Write "            var val = $(""input:radio[name='MobanType']:checked"").val();" & vbCrlf
	Response.Write "            if (!val){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""模板类型不能为空！请选择！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        MobanContent: function (value, item) {" & vbCrlf
	Response.Write "            if (!MobanContent.getValue()){" & vbCrlf
	Response.Write "                MobanContent.focus();" & vbCrlf
	Response.Write "                return ""模板代码不能为空！请填写！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "    });" & vbCrlf
	Response.Write "    //监听 文件类型" & vbCrlf
	Response.Write "    form.on('radio(FileType)', function(data){" & vbCrlf
	Response.Write "        if(data.value=='html'){" & vbCrlf
	Response.Write "            MobanSetting.style.display='';" & vbCrlf
	Response.Write "            MobanTypehtml.style.display='';" & vbCrlf
	Response.Write "            MobanTypecss.style.display='none';" & vbCrlf
	Response.Write "            $(""input:radio[name='MobanType'][value='1']"").prop(""checked"", true);" & vbCrlf
	Response.Write "            $(""input:radio[name='MobanType'][value='6']"").prop(""checked"", false);" & vbCrlf
	Response.Write "            form.render();" & vbCrlf
	Response.Write "        }else{" & vbCrlf
	Response.Write "            MobanSetting.style.display='none';" & vbCrlf
	Response.Write "            MobanTypehtml.style.display='none';" & vbCrlf
	Response.Write "            MobanTypecss.style.display='';" & vbCrlf
	Response.Write "            $(""input:radio[name='MobanType'][value='6']"").prop(""checked"", true);" & vbCrlf
	Response.Write "            $(""input:radio[name='MobanType'][value='1']"").prop(""checked"", false);" & vbCrlf
	Response.Write "            form.render();" & vbCrlf
	Response.Write "        }" & vbCrlf
	Response.Write "    });" & vbCrlf
	Response.Write "    //提交监听" & vbCrlf
	Response.Write "    form.on('submit(submit)', function (data) {" & vbCrlf
	Response.Write "        loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrlf
	Response.Write "        var radios = document.getElementsByName('FileType');" & vbCrlf
	Response.Write "        for(var i=0;i<radios.length;i++){" & vbCrlf
	Response.Write "            if(radios[i].checked == true){" & vbCrlf
	Response.Write "                FileType = radios[i].value;" & vbCrlf
	Response.Write "            }" & vbCrlf
	Response.Write "        }" & vbCrlf
	Response.Write "        $.ajax({" & vbCrLf
	Response.Write "            type: 'post'," & vbCrLf
	Response.Write "            url: '?Action=SaveAdd'," & vbCrLf
	Response.Write "            data: {MobanName: $('#MobanName').val(), MobanGetName: $('#MobanGetName').val(), MobanType: $(""input:radio[name='MobanType']:checked"").val(), FileType: FileType, ThisDir: $('#ThisDir').val(), MobanContent: MobanContent.getValue()}," & vbCrLf
	Response.Write "            dataType: 'json'," & vbCrLf
	Response.Write "            success: function(res) {" & vbCrLf
	Response.Write "                layer.close(loading);" & vbCrlf
	Response.Write "                if(res.code > 0){" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
	Response.Write "                        location.href = res.url;" & vbCrlf
	Response.Write "                    });" & vbCrlf
	Response.Write "                }else{" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
	Response.Write "                }" & vbCrlf
	Response.Write "            }" & vbCrLf
	Response.Write "        });" & vbCrLf
	Response.Write "    });" & vbCrlf
	Response.Write "});" & vbCrlf
	Response.Write "</script>" & vbCrlf
	Response.Write "</body>" & vbCrLf & "</html>"
End Sub

Sub Modify()
	Response.Write "<!DOCTYPE html>" & vbCrLf
	Response.Write "<head>" & vbCrLf
	Response.Write "<title>模板管理</title>" & vbCrlf
	Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
	Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
	Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
	Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
	Response.Write "<link rel='stylesheet' type='text/css' href='../Js/Codemirror/Codemirror.css'/>" & vbCrLf
	Response.Write "<link rel='stylesheet' type='text/css' href='../Plugins/editor/css/editormd.min.css'/>" & vbCrLf
	Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/global.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/font.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
	Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/Codemirror.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/xml.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/css.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/javascript.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/htmlmixed.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script src='../Js/Codemirror/mirrorframe.js' type='text/javascript'></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/clipboard/clipboard.min.js""></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/editor/editormd.min.js""></script>" & vbCrLf
	Response.Write "<script src=""../Plugins/msg/msg-1.0.1.js""></script>" & vbCrLf
	Response.Write "</head>" & vbCrlf
	Response.Write "<body>" & vbCrlf
	Dim MobanName,MobanContent
	MobanName=trim(request("MobanName"))
	if MobanName="" Then
		Response.Write IsSuccess("请指定Html文件名！",AdminFolder&"/Moban/"&strFileName)
		Exit Sub
	end if
	Dim TmpCls
	Set TmpCls = New Cls_FileSystem
	if TmpCls.Chk_Exist(InstallDir&MobanDir&ThisDir&MobanName,1)=False Then
		Response.Write IsSuccess("错误的文件名！",AdminFolder&"/Moban/"&strFileName)
		Exit Sub
	end if
	If FoundErr=True Then Exit Sub
	MobanContent = LoadFile(InstallDir&MobanDir&ThisDir&MobanName)
	If FileType="html" Then
		Response.Write "<script language=""javascript"">" & vbCrlf
		Response.Write "var currentMode = 1;" & vbCrlf
		Response.Write "//加载 layer 模块" & vbCrlf
		Response.Write "layui.use('layer', function(){" & vbCrlf
		Response.Write "	layer = layui.layer;" & vbCrlf
		Response.Write "});" & vbCrlf
		Response.Write "function CssInsertCode(Val,Content) {" & vbCrlf
		Response.Write "if(Val != """" && Val != null){" & vbCrlf
		Response.Write "Val = Val.replace(""{$quot}"",""\"""");" & vbCrlf
		Response.Write "Val = Val.replace(""{$quot}"",""\"""");" & vbCrlf
		Response.Write "MobanContent.replaceSelection(Val,MobanContent.getCursor());" & vbCrlf
		Response.Write "MobanContent.focus()" & vbCrlf
		Response.Write "}" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "$(function(){" & vbCrLf
		Response.Write "$(""#MobanSetting img"").mousemove(function(){" & vbCrLf
		Response.Write "layer.tips($(this).attr(""dname""),this,{tips: [1, '#000']});" & vbCrLf
		Response.Write "});" & vbCrLf
		Response.Write "$(""#MobanSetting img"").mouseout(function(){" & vbCrLf
		Response.Write "layer.closeAll();" & vbCrLf
		Response.Write "});" & vbCrLf
		Response.Write "})" & vbCrLf
		Response.Write "</script>" & vbCrlf
		Response.Write "<input name=""FileType"" type=""hidden"" id=""FileType"" value=""" & FileType & """>" & vbCrlf
		Response.Write "<input name=""ThisDir"" type=""hidden"" id=""ThisDir"" value=""" & ThisDir & """>" & vbCrlf
		Response.Write "<div id=""content"" style=""width: 100%;height:100%;position: fixed;left: 0px;word-wrap: break-word;"">" & vbCrLf
		Response.Write "    <div id=""topNav"" style=""background-color: #2b2e37; color:#009688; height: 38px;line-height: 38px;padding-left: 12px; margin-left:-1px;position: absolute; z-index: 99999999999;width: 100%;"">" & vbCrLf
		Response.Write "        <div style=""padding-left: 50px;"">" & vbCrLf
		Response.Write "            <button onClick=""javascript:history.back();"" accesskey=""c"">返回上一页[C]</button>" & vbCrLf
		Response.Write "            当前修改<span id=""currentTemplateType"">" & GetMobanTypeName(ThisDir&MobanName) & "</span>：文件名称：<input type=""text"" id=""MobanName"" value=""" & MobanName & """ readonly=""readonly"" style=""border: 0px; background-color: #2b2e37; overflow: hidden; color: #009688; width: 100px;""/>文件别名：<input type=""text"" id=""MobanGetName"" value=""" & GetMobanName(ThisDir&MobanName) & """ style=""border: 0px; background-color: #2b2e37; overflow: hidden; color: #009688; width: 100px;""/>" & vbCrLf
		Response.Write "            <button id=""htmledit_mode"" onclick=""htmledit_mode();"" accesskey=""x"">代码模式[X]</button>" & vbCrLf
		Response.Write "            <span id=""baocuninit""><button id=""save"" onclick=""saveHtmlSource();"" accesskey=""s"">保存更改[S]</button></span>" & vbCrLf
		Response.Write "            <span>&nbsp;&nbsp;&nbsp;</span>" & vbCrLf
		Response.Write "            可用：" & vbCrLf
		Response.Write "            <span id=""MobanSetting"" style=""display:none;"">" & CssSelect("MobanContent","mycss",Web_IndexShowSkinID) & "&nbsp;<b>使用标签：</b>[<a href='javascript:void(0);' onClick=""ItemDialogLabel('Test','常用标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/TemplateConfig.gif"" dname=""常用标签""/></a>&nbsp;&nbsp;<a href='javascript:void(0);' onClick=""ItemDialogLabel('Test','文字列表标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?Action=List&ChannelID=1&type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/articleList.gif"" dname=""文字列表标签"" /></a>&nbsp;&nbsp;<a href='javascript:void(0);' onclick=""ItemDialogLabel('Test','图片标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?Action=Image&ChannelID=1&type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/image.gif"" dname=""图片标签"" /></a>&nbsp;&nbsp;<a href='javascript:void(0);' onclick=""ItemDialogLabel('Test','Flash标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?Action=Flash&ChannelID=1&type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/videoList.gif"" dname=""Flash标签"" /></a>&nbsp;&nbsp;<a href='javascript:void(0);' onclick=""ItemDialogLabel('Test','Flash标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?Action=Flashqq&ChannelID=1&type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/imagePlayer.gif"" dname=""Flash标签"" /></a>&nbsp;&nbsp;<a href='javascript:void(0);' onclick=""ItemDialogLabel('Test','栏目标签','" & InstallDir & "Admin/Admin/Admin_ShowLabel.asp?Action=Class&ChannelID=1&type=MobanContent',800,450,'MobanContent');""><img src=""../Images/TemplateEditor/ZList.gif"" dname=""栏目标签"" /></a>]</span>"
		Response.Write "        </div>" & vbCrLf
		Response.Write "    </div>" & vbCrLf
		Response.Write "    <iframe name=""iframe"" id=""iframe"" frameborder=""0"" style=""width:100%;height:100%;margin-top: 38px;padding-bottom: 38px;box-sizing: border-box;"" src=""?Action=ModifyContent&MobanName=" & MobanName & "&FileType=" & FileType & "&ThisDir=" & ThisDir & """></iframe>" & vbCrLf
		Response.Write "    <div id=""htmlMode"" style=""width:100%;height:100%; display:none; padding-bottom: 38px;box-sizing: border-box;"">" & vbCrLf
		Response.Write "        <style>" & vbCrLf
		Response.Write "            .CodeMirror-linenumber{" & vbCrLf
		Response.Write "                padding:0px;" & vbCrLf
		Response.Write "                padding-left:1px;" & vbCrLf
		Response.Write "            }" & vbCrLf
		Response.Write "        </style>" & vbCrLf
		Response.Write "        <div id=""editormd"" style=""width:100%; height:100%; margin-top: 38px;""></div>" & vbCrLf
		Response.Write "        <textarea id=""html_textarea"" style=""display:none;""></textarea>" & vbCrLf
		Response.Write "    </div>" & vbCrLf
		Response.Write "</div>" & vbCrLf
		Response.Write "<script>" & vbCrLf
		Response.Write "//模式切换" & vbCrLf
		Response.Write "function htmledit_mode(){" & vbCrLf
		Response.Write "    msg.loading('切换中');" & vbCrLf
		Response.Write "    document.getElementById(""htmledit_mode"").style.display='';    //将 代码模式、智能模式切换的按钮显示。智能模式下，一直优惠智能模式、代码模式的切换按钮" & vbCrLf
		Response.Write "    if(currentMode == 1){" & vbCrLf
		Response.Write "        //由智能模式切换代码模式" & vbCrLf
		Response.Write "        document.getElementById(""iframe"").style.display='none';" & vbCrLf
		Response.Write "        document.getElementById(""iframe"").style.marginTop='0px';" & vbCrLf
		Response.Write "        document.getElementById(""htmlMode"").style.display='';" & vbCrLf
		Response.Write "        document.getElementById(""MobanSetting"").style.display='';" & vbCrLf
		Response.Write "        //判断一下，如果模版页面不是正常的HTML模版，那么在切换到代码模式时，不进行赋值textarea的操作" & vbCrLf
		Response.Write "        var html = '';" & vbCrLf
		Response.Write "        try {" & vbCrLf
		Response.Write "            html = getHtmlSource();" & vbCrLf
		Response.Write "        } catch(error) {}" & vbCrLf
		Response.Write "        if(html != ''){" & vbCrLf
		Response.Write "            //由智能模式切换代码模式" & vbCrLf
		Response.Write "            document.getElementById(""html_textarea"").value=getHtmlSource();" & vbCrLf
		Response.Write "            MobanContent = editormd(""editormd"", {" & vbCrLf
		Response.Write "                width            : ""100%""," & vbCrLf
		Response.Write "                height           : ""100%""," & vbCrLf
		Response.Write "                watch            : false," & vbCrLf
		Response.Write "                toolbar          : false," & vbCrLf
		Response.Write "                codeFold         : true," & vbCrLf
		Response.Write "                searchReplace    : true," & vbCrLf
		Response.Write "                placeholder      : ""请输入"&FileType&"代码""," & vbCrLf
		Response.Write "                value            : document.getElementById(""html_textarea"").value," & vbCrLf
		Response.Write "                theme            : ""default""," & vbCrLf
		Response.Write "                mode             : ""text/"&FileType&"""," & vbCrLf
		Response.Write "                path             : '../Plugins/editor/lib/'" & vbCrLf
		Response.Write "            });" & vbCrLf
		Response.Write "        }" & vbCrLf
		Response.Write "        document.getElementById(""htmledit_mode"").innerHTML = '智能模式[X]';" & vbCrLf
		Response.Write "        currentMode = 2;" & vbCrLf
		Response.Write "    }else{" & vbCrLf
		Response.Write "        //由代码模式切换智能模式" & vbCrLf
		Response.Write "        document.getElementById(""iframe"").style.display='';" & vbCrLf
		Response.Write "        document.getElementById(""iframe"").style.marginTop='38px';" & vbCrLf
		Response.Write "        document.getElementById(""htmlMode"").style.display='none';" & vbCrLf
		Response.Write "        document.getElementById(""MobanSetting"").style.display='none';" & vbCrLf
		Response.Write "        //将editormd的值转到textarea中" & vbCrLf
		Response.Write "        document.getElementById(""html_textarea"").value = MobanContent.getValue();" & vbCrLf
		Response.Write "        var o = document.getElementById(""iframe"");" & vbCrLf
		Response.Write "        ed = document.all ? o.contentWindow.document : o.contentDocument;" & vbCrLf
		Response.Write "        ed.open();" & vbCrLf
		Response.Write "        ed.write(MobanContent.getValue());" & vbCrLf
		Response.Write "        ed.close();" & vbCrLf
		Response.Write "        " & vbCrLf
		Response.Write "        document.getElementById(""htmledit_mode"").innerHTML = '代码模式[X]';" & vbCrLf
		Response.Write "        currentMode = 1;" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "    msg.close();" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "function getHtmlSource(){" & vbCrLf
		Response.Write "    return $(window.document).find(""#iframe"")[0].contentWindow.xnx3_getHtmlSource();" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "//保存HTML源代码" & vbCrLf
		Response.Write "function saveHtmlSource(){" & vbCrLf
		Response.Write "    //html源代码" & vbCrLf
		Response.Write "    var html;" & vbCrLf
		Response.Write "    if(currentMode == 1){" & vbCrLf
		Response.Write "        //傻瓜模式，再iframe中" & vbCrLf
		Response.Write "        html = getHtmlSource();" & vbCrLf
		Response.Write "    }else{" & vbCrLf
		Response.Write "        //开发者模式，在 editormd 中获取，（已不在textarea中，textarea只是切换智能模式与代码模式的中转站）" & vbCrLf
		Response.Write "        " & vbCrLf
		Response.Write "        //将editormd的值转到textarea中" & vbCrLf
		Response.Write "        document.getElementById(""html_textarea"").value = MobanContent.getValue();" & vbCrLf
		Response.Write "        html = document.getElementById(""html_textarea"").value" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "    if(!$('#MobanName').val()){" & vbCrLf
		Response.Write "        IsAlertFocus('文件名称不能为空！请填写！','MobanName');" & vbCrLf
		Response.Write "        return false;" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "    if(!$('#MobanGetName').val()){" & vbCrLf
		Response.Write "        IsAlertFocus('文件别名不能为空！请填写！','MobanGetName');" & vbCrLf
		Response.Write "        return false;" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "    msg.loading('保存中');" & vbCrLf
		Response.Write "    $.ajax({" & vbCrLf
		Response.Write "        type: 'post'," & vbCrLf
		Response.Write "        url: '?Action=SaveModify'," & vbCrLf
		Response.Write "        data: {MobanName: $('#MobanName').val(), MobanGetName: $('#MobanGetName').val(), FileType: $('#FileType').val(), ThisDir: $('#ThisDir').val(), MobanContent: html}," & vbCrLf
		Response.Write "        dataType: 'json'," & vbCrLf
		Response.Write "        success: function(res) {" & vbCrLf
		Response.Write "            msg.close();" & vbCrLf
		Response.Write "            if(res.code > 0){" & vbCrlf
		Response.Write "                //msg.success(""保存成功"");" & vbCrLf
		Response.Write "                layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
		Response.Write "                    location.href = res.url;" & vbCrlf
		Response.Write "                });" & vbCrlf
		Response.Write "            }else{" & vbCrlf
		Response.Write "                //msg.failure(data.msg);" & vbCrLf
		Response.Write "                layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
		Response.Write "            }" & vbCrlf
		Response.Write "        }" & vbCrLf
		Response.Write "    });" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "//Jquery layer 提示" & vbCrLf
		Response.Write "$(function(){" & vbCrLf
		Response.Write "    //编辑模式" & vbCrLf
		Response.Write "    var htmledit_mode_tipindex = 0;" & vbCrLf
		Response.Write "    $(""#htmledit_mode"").hover(function(){" & vbCrLf
		Response.Write "        htmledit_mode_tipindex = layer.tips('可以快速您网站当前的编辑模式<br/><b>智能模式</b>：想改哪里点哪里，点了直接改！修改时右键还会有更多的选择！<br/><b>代码模式</b>：以最原始代码的形式提供编辑。建议有一定编程基础或者稍微懂点的专业人士使用', '#htmledit_mode', {" & vbCrLf
		Response.Write "            tips: [2, '#0FA6A8'], //还可配置颜色" & vbCrLf
		Response.Write "            time:0," & vbCrLf
		Response.Write "            tipsMore: true," & vbCrLf
		Response.Write "            area : ['310px' , 'auto']" & vbCrLf
		Response.Write "        });" & vbCrLf
		Response.Write "    },function(){" & vbCrLf
		Response.Write "        layer.close(htmledit_mode_tipindex);" & vbCrLf
		Response.Write "    })" & vbCrLf
		Response.Write "    " & vbCrLf
		Response.Write "    " & vbCrLf
		Response.Write "    //保存按钮" & vbCrLf
		Response.Write "    var save_tipindex = 0;" & vbCrLf
		Response.Write "    $(""#save"").hover(function(){" & vbCrLf
		Response.Write "        save_tipindex = layer.tips('将您当前所操作的页面保存。保存后可预览查看，刷新一下看看其是否已改变', '#save', {" & vbCrLf
		Response.Write "            tips: [2, '#0FA6A8'], //还可配置颜色" & vbCrLf
		Response.Write "            time:0," & vbCrLf
		Response.Write "            tipsMore: true" & vbCrLf
		Response.Write "        });" & vbCrLf
		Response.Write "    },function(){" & vbCrLf
		Response.Write "        layer.close(save_tipindex);" & vbCrLf
		Response.Write "    })" & vbCrLf
		Response.Write "})" & vbCrLf
		Response.Write "//默认使用的是首页，那么顶部的导航，可用标签进行显示控制" & vbCrLf
		Response.Write "document.getElementById(""currentTemplateType"").innerHTML = '" & GetMobanTypeName(ThisDir&MobanName) & "';" & vbCrLf
		Response.Write "</script>" & vbCrLf
	Else
		Response.Write "<script language=""javascript"">" & vbCrlf
		Response.Write "function CssInsertCode(Val,Content) {" & vbCrlf
		Response.Write "if(Val != """" && Val != null){" & vbCrlf
		Response.Write "Val = Val.replace(""{$quot}"",""\"""");" & vbCrlf
		Response.Write "Val = Val.replace(""{$quot}"",""\"""");" & vbCrlf
		Response.Write "MobanContent.replaceSelection(Val,MobanContent.getCursor());" & vbCrlf
		Response.Write "MobanContent.focus()" & vbCrlf
		Response.Write "}" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "$(function(){" & vbCrLf
		Response.Write "$(""#MobanSetting img"").mousemove(function(){" & vbCrLf
		Response.Write "layer.tips($(this).attr(""dname""),this,{tips: [1, '#000']});" & vbCrLf
		Response.Write "});" & vbCrLf
		Response.Write "$(""#MobanSetting img"").mouseout(function(){" & vbCrLf
		Response.Write "layer.closeAll();" & vbCrLf
		Response.Write "});" & vbCrLf
		Response.Write "})" & vbCrLf
		Response.Write "</script>" & vbCrlf
		Response.Write "<form class='layui-form layui-form-pane' action=""" & strFileName & """ method=""post"" name=""myform"">" & vbCrlf
		Response.Write "<div class=""admin-main fadeInUp animated"">" & vbCrlf
		Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrlf
		Response.Write "        <legend>修改模版内容</legend>" & vbCrlf
		Response.Write "    </fieldset>" & vbCrlf
		Response.Write "    <div class=""layui-form-item"">" & vbCrlf
		Response.Write "        <label class=""layui-form-label"">文件名称：</label>" & vbCrlf
		Response.Write "        <div class=""layui-input-4"">" & vbCrlf
		Response.Write "            <input name=""MobanName"" type=""text"" id=""MobanName"" size=""50"" value=""" & MobanName & """ readonly=""readonly"" lay-verify=""MobanName"" class=""layui-input"">" & vbCrlf
		Response.Write "        </div>" & vbCrlf
		Response.Write "    </div>" & vbCrlf
		Response.Write "    <div class=""layui-form-item"">" & vbCrlf
		Response.Write "        <label class=""layui-form-label"">文件别名：</label>" & vbCrlf
		Response.Write "        <div class=""layui-input-4"">" & vbCrlf
		Response.Write "            <input name=""MobanGetName"" type=""text"" id=""MobanGetName"" size=""50"" value=""" & GetMobanName(ThisDir&MobanName) & """ lay-verify=""MobanGetName"" class=""layui-input"">" & vbCrlf
		Response.Write "        </div>" & vbCrlf
		Response.Write "    </div>" & vbCrlf
		Response.Write "    <div class=""layui-form-item layui-form-text"">" & vbCrlf
		Response.Write "        <label class=""layui-form-label"">内容：</label>" & vbCrlf
		Response.Write "        <div class=""layui-input-block"" style=""border:1px solid #e6e6e6;"">" & vbCrlf
		Response.Write "<div id=""editormd""></div>" & vbCrlf
		Response.Write "<textarea name=""MobanContent"" id=""MobanContent"" style=""display:none;"" lay-verify=""MobanContent"">" & Server.HtmlEncode(MobanContent) & "</textarea>" & vbCrlf
		Response.Write "        <a href=""javascript:void(0);"" id=""copyCss"" class=""layui-btn layui-btn-normal""><i class=""layui-icon layui-icon-fonts-code""></i>复制</a>" & vbCrlf
		Response.Write "        </div>" & vbCrlf
		Response.Write "    </div>" & vbCrlf
		Response.Write "</div>" & vbCrlf
		Response.Write "<script type='text/javascript'>" & vbCrLf
		Response.Write "MobanContent = editormd(""editormd"", {" & vbCrLf
		Response.Write "	width : ""100%""," & vbCrLf
		Response.Write "	height : ""300px""," & vbCrLf
		Response.Write "	watch : false," & vbCrLf
		Response.Write "	toolbar : false," & vbCrLf
		Response.Write "	codeFold : true," & vbCrLf
		Response.Write "	searchReplace : true," & vbCrLf
		Response.Write "	placeholder : ""请输入"&FileType&"代码""," & vbCrLf
		Response.Write "	value : document.getElementById(""MobanContent"").value," & vbCrLf
		Response.Write "	theme : ""default""," & vbCrLf
		Response.Write "	mode : ""text/"&FileType&"""," & vbCrLf
		Response.Write "	path : '../Plugins/editor/lib/'" & vbCrLf
		Response.Write "});" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<br>" & vbCrlf
		Response.Write "<br>" & vbCrlf
		Response.Write "<br>" & vbCrlf
		Response.Write "<br>" & vbCrlf
		Response.Write "<br>" & vbCrlf
		Response.Write "<br>" & vbCrlf
		Response.Write "<input name=""FileType"" type=""hidden"" id=""FileType"" value=""" & FileType & """><input name=""ThisDir"" type=""hidden"" id=""ThisDir"" value=""" & ThisDir & """><input type=""hidden"" name=""Action"" value=""SaveModify"">" & Submit_Layui("提交修改","重新填写","确认要清空对话框内容？","javascript:history.back();","返回上一页","") & vbCrlf
		Response.Write "</form>" & vbCrlf
		Response.Write "<div id=""copyCssWrap"" class=""copyCssWrap layui-layer-wrap"">" & vbCrLf
		Response.Write "    <textarea id=""cssTextarea"" readonly=""readonly""></textarea>" & vbCrLf
		Response.Write "    <a href=""javascript:layer.closeAll('page');"" id=""copyCssBtn"" class=""layui-btn layui-btn-normal"" data-clipboard-target=""#cssTextarea"">一键复制</a>" & vbCrLf
		Response.Write "</div>" & vbCrLf
		Response.Write "<script>" & vbCrlf
		Response.Write "layui.use(['form'], function () {" & vbCrlf
		Response.Write "    var form = layui.form;" & vbCrlf
		Response.Write "    //监听复制事件" & vbCrlf
		Response.Write "    $(""#copyCss"").click(function () {" & vbCrLf
		Response.Write "        var currentCss = MobanContent.getValue();" & vbCrLf
		Response.Write "        if (currentCss !== ''){" & vbCrLf
		Response.Write "            $('#copyCssWrap textarea').val(currentCss);" & vbCrLf
		Response.Write "            layer.open({" & vbCrLf
		Response.Write "                type: 1" & vbCrLf
		Response.Write "                ,title: '<i class=""layui-icon layui-icon-fonts-code""></i> 复制'" & vbCrLf
		Response.Write "                ,id: 'Copy_Css'" & vbCrLf
		Response.Write "                ,content: $('#copyCssWrap')" & vbCrLf
		Response.Write "                ,maxWidth: '100%'" & vbCrLf
		Response.Write "            });" & vbCrLf
		Response.Write "        }" & vbCrLf
		Response.Write "    });" & vbCrLf
		Response.Write "    var clipboard = new ClipboardJS('#copyCssBtn');" & vbCrlf
		Response.Write "    clipboard.on('success', function(e) {" & vbCrlf
		Response.Write "        layer.msg('已复制');" & vbCrlf
		Response.Write "        e.clearSelection();" & vbCrlf
		Response.Write "    });" & vbCrlf
		Response.Write "    //自定义表单验证" & vbCrlf
		Response.Write "    form.verify({" & vbCrlf
		Response.Write "        MobanName: function (value, item) {" & vbCrlf
		Response.Write "            if (!value){" & vbCrlf
		Response.Write "                item.focus();" & vbCrlf
		Response.Write "                return ""文件名称不能为空！请填写！"";" & vbCrlf
		Response.Write "            }" & vbCrlf
		Response.Write "        }," & vbCrlf
		Response.Write "        MobanGetName: function (value, item) {" & vbCrlf
		Response.Write "            if (!value){" & vbCrlf
		Response.Write "                item.focus();" & vbCrlf
		Response.Write "                return ""文件别名不能为空！请填写！"";" & vbCrlf
		Response.Write "            }" & vbCrlf
		Response.Write "        }," & vbCrlf
		Response.Write "        MobanContent: function (value, item) {" & vbCrlf
		Response.Write "            if (!MobanContent.getValue()){" & vbCrlf
		Response.Write "                MobanContent.focus();" & vbCrlf
		Response.Write "                return ""模板代码不能为空！请填写！"";" & vbCrlf
		Response.Write "            }" & vbCrlf
		Response.Write "        }," & vbCrlf
		Response.Write "    });" & vbCrlf
		Response.Write "    //提交监听" & vbCrlf
		Response.Write "    form.on('submit(submit)', function (data) {" & vbCrlf
		Response.Write "        loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrlf
		Response.Write "        $.ajax({" & vbCrLf
		Response.Write "            type: 'post'," & vbCrLf
		Response.Write "            url: '?Action=SaveModify'," & vbCrLf
		Response.Write "            data: {MobanName: $('#MobanName').val(), MobanGetName: $('#MobanGetName').val(), FileType: $('#FileType').val(), ThisDir: $('#ThisDir').val(), MobanContent: MobanContent.getValue()}," & vbCrLf
		Response.Write "            dataType: 'json'," & vbCrLf
		Response.Write "            success: function(res) {" & vbCrLf
		Response.Write "                layer.close(loading);" & vbCrlf
		Response.Write "                if(res.code > 0){" & vbCrlf
		Response.Write "                    layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
		Response.Write "                        location.href = res.url;" & vbCrlf
		Response.Write "                    });" & vbCrlf
		Response.Write "                }else{" & vbCrlf
		Response.Write "                    layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
		Response.Write "                }" & vbCrlf
		Response.Write "            }" & vbCrLf
		Response.Write "        });" & vbCrLf
		Response.Write "    });" & vbCrlf
		Response.Write "});" & vbCrlf
		Response.Write "</script>" & vbCrlf
	End If
	Response.Write "</body>" & vbCrLf & "</html>"
End Sub

Sub SaveAdd()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		dim MobanID,MobanName,MobanGetName,MobanContent
		FileType=Trim(Request.Form("FileType"))
		ThisDir=Trim(Request.Form("ThisDir"))
		MobanName=Trim(Request.Form("MobanName"))
		MobanGetName=Trim(Request.Form("MobanGetName"))
		MobanType=Trim(Request.Form("MobanType"))
		MobanContent=ShiftCharacterSave(Trim(Request.Form("MobanContent")))
		If MobanType="" Then MobanType = 1
		
		If ThisDir<>"" Then
			ThisDir=Replace(ThisDir & "/","//","/")
		End If
		
		If MobanName="" Then
			Response.Write "{""code"":0,""msg"":""\u6587\u4ef6\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If MobanGetName="" Then
			Response.Write "{""code"":0,""msg"":""\u6587\u4ef6\u522b\u540d\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If FileType="" Then
			Response.Write "{""code"":0,""msg"":""\u6587\u4ef6\u7c7b\u578b\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If MobanContent="" Then
			Response.Write "{""code"":0,""msg"":""\u5185\u5bb9\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		
		If FoundErr = True Then Exit Sub
		
		If FileType="css" Then
			MobanDir=SkinDir
			MobanContent=Replace(MobanContent,"{$InstallDir}",InstallDir,1,-1,1)
			ThisDir=""
			MobanType = 6
		Else
			FileType="html"
			MobanDir=TemplateDir
		End If
		MobanName = Replace(MobanName,"."&FileType,"")
		MobanID = GetNewID(Data_Name, "MobanID")
		sql="select * from "&Data_Name&" where MobanName='" & ThisDir & MobanName & "." & FileType & "'"
		Call Exe_Conn(rs,sql,3)
		If Not (rs.BOF And rs.EOF) Then
			rs("MobanName")=ThisDir & MobanName & "." & FileType
			rs("MobanGetName")=MobanGetName
			rs("MobanType")=MobanType
			rs.Update
			rs.Close
			Set rs = Nothing
		Else
			rs.addnew
			rs("MobanID")=MobanID
			rs("MobanName")=ThisDir & MobanName & "." & FileType
			rs("MobanGetName")=MobanGetName
			rs("MobanType")=MobanType
			rs.Update
			rs.Close
			Set rs = Nothing
		End If
		Dim TmpCls
		Set TmpCls = New Cls_FileSystem
		If TmpCls.Chk_Exist(InstallDir&MobanDir&ThisDir&MobanName&"."&FileType,1)=True Then
			Response.Write "{""code"":0,""msg"":""\u5df2\u7ecf\u5b58\u5728\u6b64\u6587\u4ef6\uff08"&MobanName&"."&FileType&"\uff09\uff01""}" & vbCrLf
			Response.End()
		End If
		Call TmpCls.Make_Dir(InstallDir&MobanDir)
		Call TmpCls.Make_Dir(InstallDir&MobanDir&ThisDir)
		WriteTOFile InstallDir&MobanDir&ThisDir&MobanName&"."&FileType,MobanContent
		Set TmpCls = Nothing
		Response.Write "{""code"":1,""msg"":""\u6a21\u677f\u6dfb\u52a0\u6210\u529f\uff01"",""url"":""?Action=Main&FileType=" & FileType & "&ThisDir="&ThisDir&"""}" & vbCrLf
		Response.End()
		Exit Sub
	End If
End Sub

Sub SaveModify()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		dim MobanID,MobanName,MobanGetName,MobanContent
		FileType=Trim(Request.Form("FileType"))
		ThisDir=Trim(Request.Form("ThisDir"))
		MobanName=Trim(Request.Form("MobanName"))
		MobanGetName=Trim(Request.Form("MobanGetName"))
		MobanContent=ShiftCharacterSave(Trim(Request.Form("MobanContent")))
		MobanContent=LoseHtml(MobanName,MobanContent)
		
		If ThisDir<>"" Then
			ThisDir=Replace(ThisDir & "/","//","/")
		End If
		
		If MobanName="" Then
			Response.Write "{""code"":0,""msg"":""\u6587\u4ef6\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If MobanGetName="" Then
			Response.Write "{""code"":0,""msg"":""\u6587\u4ef6\u522b\u540d\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If FileType="" Then
			Response.Write "{""code"":0,""msg"":""\u6587\u4ef6\u7c7b\u578b\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If MobanContent="" Then
			Response.Write "{""code"":0,""msg"":""\u5185\u5bb9\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		
		If FoundErr = True Then Exit Sub
		
		If FileType="css" Then
			MobanDir=SkinDir
			MobanContent=Replace(MobanContent,"{$InstallDir}",InstallDir,1,-1,1)
		Else
			FileType="html"
			MobanDir=TemplateDir
		End If
		MobanName = Replace(MobanName,"."&FileType,"")
		MobanID = GetNewID(Data_Name, "MobanID")
		sql="select * from "&Data_Name&" where MobanName='" & ThisDir & MobanName & "." & FileType & "'"
		Call Exe_Conn(rs,sql,3)
		If Not (rs.BOF And rs.EOF) Then
			rs("MobanName")=ThisDir & MobanName & "." & FileType
			rs("MobanGetName")=MobanGetName
			rs.Update
			rs.Close
			Set rs = Nothing
		Else
			rs.addnew
			rs("MobanID")=MobanID
			rs("MobanName")=ThisDir & MobanName & "." & FileType
			rs("MobanGetName")=MobanGetName
			rs.Update
			rs.Close
			Set rs = Nothing
		End If
		Dim TmpCls
		Set TmpCls = New Cls_FileSystem
		Call TmpCls.Make_Dir(InstallDir&MobanDir)
		Call TmpCls.Make_Dir(InstallDir&MobanDir&ThisDir)
		WriteTOFile InstallDir&MobanDir&ThisDir&MobanName&"."&FileType,MobanContent
		Set TmpCls = Nothing
		Response.Write "{""code"":1,""msg"":""\u6a21\u677f\u4fee\u6539\u6210\u529f\uff01"",""url"":""?Action=Main&FileType=" & FileType & "&ThisDir="&ThisDir&"""}" & vbCrLf
		Response.End()
		Exit Sub
	End If
End Sub

Sub Update()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		dim MobanID,MobanName,MobanGetName
		FileType=Trim(Request.Form("FileType"))
		ThisDir=Trim(Request.Form("ThisDir"))
		MobanName=Trim(Request.Form("MobanName"))
		MobanGetName=Trim(Request.Form("MobanGetName"))
		If ThisDir<>"" Then
			ThisDir=Replace(ThisDir & "/","//","/")
		End If
		
		If MobanName="" Or MobanName=".." Then
			Response.Write "{""code"":0,""msg"":""\u6587\u4ef6\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If MobanGetName="" Then
			Response.Write "{""code"":0,""msg"":""\u6587\u4ef6\u522b\u540d\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If FileType="" Then
			Response.Write "{""code"":0,""msg"":""\u6587\u4ef6\u7c7b\u578b\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		
		If FoundErr = True Then Exit Sub
		
		If FileType="css" Then
			MobanDir=SkinDir
		Else
			FileType="html"
			MobanDir=TemplateDir
		End If
		MobanID = GetNewID(Data_Name, "MobanID")
		sql="select * from "&Data_Name&" where MobanName='" & ThisDir & MobanName & "'"
		Call Exe_Conn(rs,sql,3)
		If Not (rs.BOF And rs.EOF) Then
			rs("MobanName")=ThisDir & MobanName
			rs("MobanGetName")=MobanGetName
			rs.Update
			rs.Close
			Set rs = Nothing
		Else
			rs.addnew
			rs("MobanID")=MobanID
			rs("MobanName")=ThisDir & MobanName
			rs("MobanGetName")=MobanGetName
			rs.Update
			rs.Close
			Set rs = Nothing
		End If
		Response.Write "{""code"":1,""msg"":""\u6587\u4ef6\u522b\u540d\u4fee\u6539\u6210\u529f\uff01"",""url"":""?Action=Main&FileType=" & FileType & "&ThisDir="&ThisDir&"""}" & vbCrLf
		Response.End()
		Exit Sub
	End If
End Sub

Sub ModifyContent()
	Response.Write "<script type='text/javascript'>var pc_file = '" & InstallDir & "';var admin_file = '" & AdminFolder & "/';</script>" & vbCrLf
	Response.Write "<script src=""../Plugins/htmledit/htmledit.js""></script>" & vbCrLf
	MobanContent = LoadFile(InstallDir&MobanDir&Request.QueryString("ThisDir")&Request.QueryString("MobanName"))
	MobanContent = Replace(MobanContent,"{$InstallDir}",InstallDir,1,-1,1)
	MobanContent = Replace(MobanContent,"{$SkinDir}",SkinDir,1,-1,1)
	Response.Write MobanContent
End Sub

Sub MobanPreview()
	Dim MobanName,HtmlContent
	Tit="模板样式预览"
	MobanName=Request.QueryString("MobanName")
	ThisDir=Request.QueryString("ThisDir")
	If ThisDir<>"" Then
		HtmlContent = ChannelTemplate(ThisDir&MobanName,Web_IndexShowSkinID,ChannelID)
	Else
		HtmlContent = Template(ThisDir&MobanName,Web_IndexShowSkinID,0)
	End If
	Response.Write HtmlContent
End Sub

Sub DelAll()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Dim MobanID,FileId,FileNum,FilePath
		FileType = Trim(Request("FileType"))
		ThisDir = Trim(Request("ThisDir"))
		FileId = Trim(Request("FileId"))
		Call Exec(Rs,"Select Top 1 MobanID From ["&Data_Name&"] Where MobanName='" & ThisDir & FileId & "'",2)
		If Rs.Eof Then
			MobanID = ""
			Rs.Close
		Else
			MobanID = Rs("MobanID")
			Rs.Close
		End If
		If ThisDir<>"" Then
			ThisDir=Replace(ThisDir & "/","//","/")
		End If
		If FileType="css" Then
			MobanDir=SkinDir
			ThisDir=""
		Else
			FileType="html"
			MobanDir=TemplateDir
		End If
		TopDir=Replace(InstallDir&MobanDir,"//","/")
		FileNum=0
		If instr(FileId,",")>0 Then
			FileId = Split(FileId,",")
			If Ubound(FileId) > -1 Then
				For i = 0 to Ubound(FileId)
					Call Exec("","Delete From "&Data_Name&" Where MobanName='" & ThisDir & FileId & "'",0)
					Call Exec("","Update ["&Data_Name&"] Set MobanID=MobanID-1 Where MobanID>"&MobanID,0)
					FilePath = Server.MapPath(TopDir & ThisDir & trim(FileId(i)))
					If Fso.FileExists(FilePath) Then
						Fso.DeleteFile FilePath,true
						FileNum = FileNum + 1
					End If
				Next
			End If
		Else
			Call Exec("","Delete From "&Data_Name&" Where MobanName='" & ThisDir & FileId & "'",0)
			Call Exec("","Update ["&Data_Name&"] Set MobanID=MobanID-1 Where MobanID>"&MobanID,0)
			FilePath = Server.MapPath(TopDir & ThisDir & FileId)
			If Fso.FileExists(FilePath) Then
				Fso.DeleteFile FilePath,true
				FileNum = FileNum + 1
			End If
		End If
		Response.Write "{""msg"":""\u6210\u529f\u5220\u9664\u6587\u4ef6\uff08"& FileId &"\uff09\uff01"",""code"":1}"
		Response.End()
	End If
End Sub
%>